import { redis } from '@/config/redis';
import { success } from '@/config/response';
import { Router } from 'express';

const router = Router();

router.post('/share', async (req, res) => {
  const { data } = req.body;
  redis.set(data.id, data);
  success(res, data);
});
router.get('/share', async (req, res) => {
  const { id } = req.query;
  if (id) {
    const data = await redis.get(`${id}`);
    if (data) {
      JSON.parse(data);
      success(res, data);
      return;
    }
  }
  success(res, null, '没有数据');
});

export default router;
